#include  <cstdio>

int main(int argc, char *argv[])
{
	int n,ct = 0;
	int arr[50];

	scanf("%d",&n);
	while( n != 0 )
	{
		int sum = 0;
		for( int i = 0 ; i < n ; ++i )
		{
			scanf("%d",&arr[i]);
			sum += arr[i];
		}

		int avg = sum / n;
		sum = 0;
		for( int i = 0 ; i < n ; ++i )
			if(avg > arr[i])
				sum += avg - arr[i];
		
		printf("Set #%d\nThe minimum number of moves is %d.\n\n",
				++ct,sum);
		scanf("%d",&n);
	}
}
